package prueba;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


public class UsuarioAvanza extends MIDlet implements CommandListener {

	Display pantalla;
	Form form;
	Command comando1;
	TextField usuario;
	TextField pass;
	Command continuar;
	Form formcontinuar;
	
	public UsuarioAvanza() {
		// TODO Auto-generated constructor stub
		pantalla=Display.getDisplay(this);
		usuario= new TextField("Usuario:","",10,TextField.ANY);
		pass= new TextField("Password:","",10,TextField.PASSWORD);
		form=new Form("Validacion");
		form.append(usuario);
		form.append(pass);
		
		continuar=new Command("Continuar",Command.OK, 0);
		form.addCommand(continuar);
		pantalla.setCurrent(form);
		form.setCommandListener(this);

		
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	public void commandAction(Command arg0, Displayable arg1) {
		// TODO Auto-generated method stub
		if(arg0.equals(continuar)){
			if(usuario.getString().equals("mario") && pass.getString().equals("mario1")){
				formcontinuar = new Form("validacion Aceptada");
				pantalla.setCurrent(formcontinuar);
			}else{
				form.append("Error, no has introducido correctamente los datos");
				usuario.delete(0, usuario.size());
				pass.delete(0, pass.size());
			}
		}
	}

}
